package org.dandelero.properties.util;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.Properties;

/**
 * Provides a useful set of methods for loading properties.
 * 
 * @author dandelero
 */
public class PropertiesLoader {

	/**
	 * Loads the properties from the given file.
	 * 
	 * @param file
	 *            the file.
	 * @return the properties in the given file.
	 * @throws IOException
	 *             if the file could not be loaded.
	 */
	public static Properties loadPropertiesFile(File file) throws IOException {
		final Properties props = new Properties();
		props.load(new FileInputStream(file));
		return props;
	}

	/**
	 * Loads the properties from the given file.
	 * 
	 * @param file
	 *            the file.
	 * @return the properties in the given file.
	 * @throws IOException
	 *             if the file could not be loaded.
	 */
	public static Properties loadPropertiesFile(String file) throws IOException {
		return loadPropertiesFile(new File(file));
	}
}
